<template>
  <el-dialog
    :title="title"
    :visible="visible"
    :close-on-click-modal="false"
    destroy-on-close
    width="500px"
    @close="visible=false"
  >
    <el-form
      v-if="visible"
      ref="form"
      :model="entityData"
      :rules="rules"
      label-width="120px"
      label-position="right"
      style="width:90%;margin:0px auto;"
    >
      <!--表单区域 -->
      <el-form-item label="应用" prop="appId">
        <app-single-select
          ref="appSingleSelect"
          v-model="entityData.appId"
          :name="entityData.appName"
          @changeSelect="changeSelect"
        />
      </el-form-item>
      <el-form-item label="数据角色编码" prop="roleCode">
        <dictionary-select
          v-model="entityData.roleCode"
          :readonly="readonly"
          :code="$constant.DATA_ROLE"
        />
      </el-form-item>
      <el-form-item label="业务编码" prop="businessCode">
        <el-input v-model="entityData.businessCode" :readonly="readonly" />
      </el-form-item>
      <el-form-item label="二级业务编码" prop="businessCodeSecond">
        <el-input v-model="entityData.businessCodeSecond" :readonly="readonly" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button v-show="saveButtonVisible" type="primary" @click="save">保存</el-button>
      <el-button @click="close">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { detailMixin } from '@/mixin/detailMixin'
import appSingleSelect from '../apiApp/singleSelect'
const MODULE_CODE = 'cip'
const ENTITY_TYPE = 'apiDataPermission'
export default {
  name: ENTITY_TYPE + '-detail',
  components: { appSingleSelect },
  mixins: [detailMixin],
  data() {
    return {
      entityType: ENTITY_TYPE,
      moduleCode: MODULE_CODE,
      // eslint-disable-next-line no-eval
      api: eval('this.$api.' + MODULE_CODE + '.' + ENTITY_TYPE),
      pageCode: MODULE_CODE + ':' + ENTITY_TYPE + ':',
      entityData: {

      },
      rules: {
        // 前端验证规则
        appId: [
          { required: true, message: '请选择应用', trigger: 'blur' }
        ],
        roleCode: [
          { required: true, message: '请选择数据角色', trigger: 'blur' }
        ],
        businessCode: [
          { required: true, message: '请输入业务编码', trigger: 'blur' }
        ]

      }
    }
  },
  methods: {
    changeSelect(value, name) {
      this.entityData.appId = value
      this.entityData.appName = name
    }

  }

}
</script>

<style lang="scss">
</style>
